<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        function Person1(name, age, job) {
            this.name = name
            this.age = age
            this.job = job

        }
        Person1.prototype.sayName = function () {
            console.log(`Hello everybody i am ${this.name}`)
        }
        Person1.prototype.sayAge = function () {
            console.log(`I am ${this.age} years old`)
        }
        let p1 = new Person1('lilei', 28, 'Java Engineer')

        function Person2(name, age, job) {
            this.name = name
            this.age = age
            this.job = job
        }
        Person2.prototype = {
            sayName: function () {
                console.log(`Hello everybody i am ${this.name}`)
            },
            sayAge: function () {
                console.log(`I am ${this.age} years old`)
            }
        }
        let p2 = new Person2('lily', 25, 'web Engineer')

        function SuperType() {
            this.property = true;
        }
        
        SuperType.prototype.getSuperValue = function () {
            return this.property;
        };

        function SubType() {
            this.subproperty = false;
        }
        //继承了 SuperType 
        SubType.prototype = new SuperType();
        SubType.prototype.getSubValue = function () {
            return this.subproperty;
        };
        var instance = new SubType();
        alert(instance.getSuperValue()); //true
    </script>
</body>

</html>